﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Reflection;

namespace VietPublisher.BaseProject
{
    public static class Enums
    {
        public static string GetStringValue(this Enum value)
        {
            // Get the type
            Type type = value.GetType();

            // Get fieldinfo for this type
            FieldInfo fieldInfo = type.GetField(value.ToString());

            // Get the stringvalue attributes
            StringValueAttribute[] attribs = fieldInfo.GetCustomAttributes(
                typeof(StringValueAttribute), false) as StringValueAttribute[];

            // Return the first if there was a match.
            return attribs.Length > 0 ? attribs[0].StringValue : null;
        }

        public enum UserTypes
        {
            ADMIN,
            CUSTOMER
        }

        public enum SexType
        {
            MALE,
            FEMALE
        }

        public enum UserYN
        {
            YES,
            NO
        }

        public enum PaymentMethod
        {
            CREDITCARD
        }

        public enum OrderStatus
        {
            /* dong lai */
               [StringValue("Closed")]
            CLOSED,
            /* Da giao */
               [StringValue("Delivered")]
            DELIVERED,
            /* goi di */
               [StringValue("Dispatched")]
            DISPATCHED,
            /* moi */
               [StringValue("New")]
            NEW,
            /*Dong goi*/
               [StringValue("Packed")]
            PACKED
        }

        public enum FileTypes
        {
            JPG,
            JPEG,
            GIF
        }

        /// <summary>
        /// Tieu chi tim kiem
        /// </summary>
        public enum CriterionSearch 
        { 
            BOOKTITLE,
            AUTHORNAME,
            PUBLISHER,
            ALL
        }

    }
    public class StringValueAttribute : Attribute
    {

        #region Properties

        /// <summary>
        /// Holds the stringvalue for a value in an enum.
        /// </summary>
        public string StringValue { get; protected set; }

        #endregion

        #region Constructor

        /// <summary>
        /// Constructor used to init a StringValue Attribute
        /// </summary>
        /// <param name="value"></param>
        public StringValueAttribute(string value)
        {
            this.StringValue = value;
        }

        #endregion


    }


    public enum UserValidateStatus
    {
        Success,
        InvalidUserName,
        InvalidPassword,
        IsLockedOut,
        IsNotApproved
    }

    public enum UserRegistErrorState
    {
        DuplicateMobile,
        NoRegistEntry,
        AuthCodeTimeOut,
        RegistCompleted
    }

    public enum UserResignErrorState
    {
        UserNotExist,
        ResignCompleted,
        AlreadyResigned,
        UnknowError
    }

    public enum ChangePassErrorState
    {
        UserNotExist,
        PassTooLong,
        PINPattenNotSet,
        InvalidPassword,
        Success
    }

   
    public class FileViewInfo
    {
        public int No { get; set; }
        public int GroupId { get; set; }
        public Guid FileId { get; set; }
        public string Name { get; set; }
        public decimal Size { get; set; }
        public string FileSize { get; set; }
        public string Ext { get; set; }
        public string PhysicalPath { get; set; }
        public string FileLink { get; set; }
    }

}
